package com.limf.demo.arithmetic;

import java.util.HashSet;
import java.util.Random;
import java.util.Set;

public class ArithmeticTest1 {

	public static void main(String[] args) {
		int value = 1000_0000;
		Set<Integer> result = new HashSet(value);
		
		Random random = new Random();
		long a = System.currentTimeMillis();
		while(result.size() <= value) {
			int i=random.nextInt(value + 1);
			result.add(i);
		}
		long b = System.currentTimeMillis();
		System.out.println("使用了 " + (b-a) + "ms");
		try {
			Thread.sleep(2000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}   // 暂停2秒
		//result.stream().forEach(System.out::println);
		System.out.println(result.size());
	}
	
}
